#------------------------- global options -------------------------#

output_dir = bin
source_dir = src
include_dir = inc
object_dir = obj

CXX = g++
FLAGS = -g

# default to linux
PLATFORM = LINUX

ifeq ($(PLATFORM), WINDOWS)
	mkdir_cmd = mkdir
	rm_cmd = rmdir /S /Q
endif

ifeq ($(PLATFORM), LINUX)
	mkdir_cmd = mkdir -p
	rm_cmd = rm -rf
endif


#------------------------- targets -------------------------#

all: yavrs

.PHONY: clean
clean:
	$(rm_cmd) obj bin doc

$(object_dir):
	$(mkdir_cmd) $(object_dir)

$(output_dir):
	$(mkdir_cmd) $(output_dir)


#------------------------- yavrs -------------------------#

yavrs_bin_file = $(output_dir)/libyavrs.a

yavrs_obj_files = $(object_dir)/yavrsOmega.o $(object_dir)/yavrsCamera.o $(object_dir)/yavrsWavefrontObj.o

yavrs: $(yavrs_bin_file)

$(yavrs_bin_file): $(yavrs_obj_files) | $(output_dir)
	ar rcs $(yavrs_bin_file) $(yavrs_obj_files)


#------------------------- header dependencies  -------------------------#
#
# Recompile .o files and recreate related binaries whenever included
# headers change
#

$(object_dir)/omega.o: $(source_dir)/omega.h


#------------------------- pattern rules -------------------------#

# rule to make .o files from .cpp files
$(object_dir)/%.o: $(source_dir)/%.cpp | $(object_dir)
	$(CXX) -I$(include_dir) $(FLAGS) -o $@ -c $<

